Page({
    data: {
      searchKeyword: '', // 搜索关键词
      genders: ['不限', '男', '女'], // 性别筛选选项
      selectedGenderIndex: 0, // 选中的性别索引
      locations: ['不限', '地址1', '地址2', '地址3'], // 地址筛选选项
      selectedLocationIndex: 0, // 选中的地址索引
      users: [
        // 用户数据示例，实际需要从数据库或其他来源获取
        { nickName: '用户1', account: 'user1', gender: 1, address: '地址1' },
        { nickName: '用户2', account: 'user2', gender: 2, address: '地址2' },
        { nickName: '用户3', account: 'user3', gender: 1, address: '地址3' },
        // 添加更多用户数据
      ],
    },
  
    onSearchInput(e) {
      this.setData({
        searchKeyword: e.detail.value,
      });
    },
  
    onGenderChange(e) {
      this.setData({
        selectedGenderIndex: e.detail.value,
      });
    },
  
    onLocationChange(e) {
      this.setData({
        selectedLocationIndex: e.detail.value,
      });
    },
  
    search() {
      const { users, searchKeyword, selectedGenderIndex, selectedLocationIndex, genders, locations } = this.data;
      const filteredUsers = users.filter((user) => {
        const genderMatch = selectedGenderIndex === 0 || user.gender === selectedGenderIndex;
        const locationMatch = selectedLocationIndex === 0 || user.address === locations[selectedLocationIndex];
        const keywordMatch = user.nickName.includes(searchKeyword) || user.account.includes(searchKeyword);
        return genderMatch && locationMatch && keywordMatch;
      });
      this.setData({
        filteredUsers: filteredUsers,
      });
    },
  });
  